package com.imchen.cms.cmscore.service;

import com.imchen.cms.cmscore.dao.FileTypeMapper;
import com.imchen.cms.exception.CmsException;
import com.imchen.cms.cmscore.model.FileType;
import com.imchen.cms.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author imchen
 * @create: 2019-01-30 14:48
 **/
@Service
public class FileTypeService implements BaseService<FileType>{

    @Autowired
    private FileTypeMapper mapper;

    @Override
    public HashMap<String, Integer> add(FileType fileType) throws CmsException {
        int count= mapper.insertSelective(fileType);
        int id= fileType.getId();
        return ServiceUtil.toAddMap(count,id);
    }

    @Override
    public FileType findById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int removeById(int id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteById(int id) {
        return 0;
    }

    @Override
    public int update(FileType fileType) {
        return mapper.updateByPrimaryKeySelective(fileType);
    }
}